package ch06.shangJi;

import org.apache.log4j.Logger;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class UserDaoLogger {
    private static final Logger logger=Logger.getLogger(UserDaoLogger.class.getName());
    @Pointcut("execution(* ch06.shangJi.UserServiceImpl.*(..))")
    public void pointcut(){}
    @Before("pointcut()")
    public void before(JoinPoint joinPoint){
        logger.info("调用"+joinPoint.getTarget()+"类里面的方法，方法"+joinPoint.getSignature().getName());
    }


    @After("pointcut()")
    public  void after(JoinPoint jp){
        logger.info(jp.getSignature().getName()+"结束方法执行");
    }
}
